package com.ruiboyun.liveapp.util.tool;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * Created by 吴世芊 on 2016/11/10.
 * Update by  on
 * 公司:杭州无尽信息科技有限公司
 * 邮箱：apple9302@126.com
 * Description:

 */

public class JsonUtils {
    public static <T> T parseObject(String text, Class<T> clazz) {
        try {
            T t = JSON.parseObject(text, clazz);
            return t;
        } catch (Exception e) {
            Loger.e(e.getMessage()+"解析异常"+text);
            e.printStackTrace();
            return null;
        }

    }
    public static JSONObject parseObject(String text){
        JSONObject jsonObject = JSONObject.parseObject(text);
        return jsonObject;
    }

    public static <T> List<T> parseArray(String text, Class<T> clazz) {
        try {

            List<T> ts = JSON.parseArray(text, clazz);
            return ts;
        } catch (Exception e) {
            Loger.e(e.getMessage()+"解析异常"+text);
            e.printStackTrace();
            return null;
        }
    }
}
